package com.wqc;

import com.wqc.model.User;
import com.wqc.service.UserService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringRedisApplication {

    public static void main(String[] args) {
        //这里之所以只加载applicationContext.xml是因为我把spring-Redis.xml的配置直接放进了applicationContext.xml，不要问我为什么，因为我骚啊。
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-redis.xml");
        UserService userService = context.getBean(UserService.class);

        String name="zhangsan";

        User user = new User();
        user.setId(1);
        user.setName(name);
        user.setPhone("18988666688");
        user.setAddress("东京市南京区西京大道北京街");

        System.out.println("==== putting objects into redis ====");
        userService.put(user);

        System.out.println("==== getting objects from redis ====");
        User result = userService.get(user);
        System.out.println("result:"+result);

        System.out.println("==== deleting objects from redis ====");
        //userService.delete(user);

        System.out.println("==== getting objects from redis ====");
        User result2 = userService.get(user);
        System.out.println("result2:"+result2);
    }

}
